#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <string.h>
#include <stdlib.h>

int main(){
    char *const argv[] = {"ls", "-l", "-a", NULL};
    char *const env[] = {"hello1", "hello2", NULL};
    pid_t id = fork();
    if(id == 0){
	//execl("./other", "other", NULL);
	//execv("/bin/ls", argv);
	//execlp("ls", "ls", "-l", "-a",  NULL);
	//execvp("ls", argv);
	//execle("./other", "other", NULL, env);
	execve("./other", argv, env);


	printf("我是子进程，pid:%d\n", getpid());
	exit(0);
    }
    else{
	printf("我是父进程, pid:%d\n", getpid());
        pid_t rid = waitpid(id, NULL, 0);
	if(rid > 0){
	    printf("成功等待子进程！\n");
	}
    }
    return 0;
}
